<template>
	<view>
		<view class="main">
			<view class="main-head">
				<view class="main-head-con flex align-item">
					<view class="main-head-con-logo">
						<image :src=" imgUrl + 'static/web/img/hunlianlogo.png'" mode=""></image>
					</view>
					<view class="main-head-con-info">
						<view class="main-head-con-info-tit">
							{{ activityData.title || '' }}
						</view>
						<view class="main-head-con-info-subtit">
							{{ activityData.subtitle || '' }}
						</view>
					</view>
				</view>
				<view class="main-head-detail flex align-item j-between">
					<view class="main-head-detail-left">
						<view class="flex align-item">
							<view class="">
								已报名：
							</view>
							<view class="con-t">
								{{ activityData.sign_up_num || '' }}
							</view>
							<view class="">
								/{{ activityData.activity_num || '' }}人
							</view>
						</view>
						<view class="flex align-item info-time">
							<view class="">
								时间：
							</view>
							<view class="">
								{{ activityData.start_time || '' }}
							</view>
						</view>
						<view class="flex align-item">
							<view class="">
								地址：
							</view>
							<view class="">
								{{ activityData.address || '' }}
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="main-con">
				<view class="con-title">
					预约信息
				</view>
				<view class="con-item flex align-item j-between">
					<view class="">
						姓名：
					</view>
					<view class="">
						{{ activityData.real_name || '' }}
					</view>
				</view>
				<view class="con-item flex align-item j-between">
					<view class="">
						电话：
					</view>
					<view class="">
						{{ activityData.order_sn || '' }}
					</view>
				</view>
			</view>
		</view>
		
		<view class="btn flex align-item" v-if="order_sn && activityData" @click="write">
			<view class="btn-hexiao">
				核销
			</view>
		</view>
	</view>
</template>

<script>
	import { mapState, mapMutations } from 'vuex';
	export default {
		data() {
			return {
				imgUrl: this.$http.baseUrl, // 服务器域名
				activity_id: '', // 活动id
				uid: '', // 用户id
				order_sn: '', // 存储核销订单号
				activityData: [], // 存储活动详情信息
			}
		},
		computed: {
			...mapState(['userInfo']),
		},
		methods: {
			getActivityData(){
				var that = this
				if(!that.uid){
					uni.showToast({
					    title: '请前往授权登录',
					    duration: 1000
					});
					setTimeout(function() {
						uni.switchTab({
							url: '/pages/my/my'
						});
					}, 1000);
				}else {
					that.$http.get('api/ZhMyActivity/heXiaoShuJu',{
						'order_sn': that.order_sn
					}).then(res => {
							if(res){
								that.activityData = res
							}
						});
				}
			},
			// 核销
			write(){
				var that = this
				that.$http.get('api/ZhMyActivity/heXiao',{
					'order_sn': that.order_sn
				}).then(res => {
						if(res){
							uni.showToast({
								title: '核销成功',
								icon: 'none'
							})
							setTimeout(()=>{
								uni.navigateBack({
									
								})
							},1500)
						}
					})
			},
		},
		onLoad(e) {
			
			this.order_sn = e.orderno
			var userInfo = this.$store.state.userInfo;
			this.uid = userInfo.uid
			this.activity_id = e.activity_id
			this.getActivityData()
		},
	}
</script>
<style>
page {
	background-color: #F9F9F9;
}
</style>
<style lang="scss" scoped>
.flex {
	display: flex;
}
.align-item {
	align-items: center;
}
.j-between {
	justify-content: space-between;
}
.column {
	flex-direction: column;
}

.main {
	padding: 0 30rpx;
	.main-head {
		background-color: #FFFFFF;
		padding: 40rpx 30rpx 40rpx;
		border-radius: 24rpx;
		.main-head-con {
			.main-head-con-logo {
				width: 120rpx;
				height: 120rpx;
				border-radius: 20rpx;
				overflow: hidden;
				image {
					width: 100%;
					height: 100%;
				}
			}
			.main-head-con-info {
				margin-left: 24rpx;
				.main-head-con-info-tit {
					font-size: 40rpx;
					font-family: PingFangSC-Semibold, PingFang SC;
					font-weight: 600;
					color: #000013;
					margin-bottom: 20rpx;
				}
				.main-head-con-info-subtit {
					font-size: 28rpx;
					font-family: PingFangSC-Light, PingFang SC;
					font-weight: 300;
					color: #6A6A7E;
				}
			}
		}
		.main-head-detail {
			margin-top: 38rpx;
			.main-head-detail-left {
				font-size: 26rpx;
				font-family: PingFangSC-Light, PingFang SC;
				font-weight: 300;
				color: #000013;
				.info-time {
					margin: 20rpx 0;
				}
				.con-t {
					color: #7F5AFF;
				}
			}
			.main-head-detail-right {
				font-size: 26rpx;
				font-family: PingFangSC-Light, PingFang SC;
				font-weight: 300;
				color: #000013;
				.daohang-logo {
					width: 64rpx;
					height: 64rpx;
					margin-bottom: 10rpx;
				}
			}
		}
	}
	.main-con {
		padding: 40rpx 30rpx;
		background-color: #fff;
		margin-top: 30rpx;
		.con-title {
			font-size: 32rpx;
			font-family: PingFangSC-Semibold, PingFang SC;
			font-weight: 600;
			color: #000013;
			margin-bottom: 40rpx;
		}
		.con-item {
			font-size: 28rpx;
			font-family: PingFangSC-Light, PingFang SC;
			font-weight: 300;
			color: #6A6A7E;
			margin-bottom: 24rpx;
		}
		.con-item:nth-child(3){
			margin-bottom: 0;
		}
	}
}
.btn {
	width: 100%;
	justify-content: center;
	margin-top: 40rpx;
	.btn-hexiao {
		width: 80%;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		background: #7F5AFF;
		border-radius: 16rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
	}
}
</style>
